<template>
  <div class="content">
    <!--    上传文件-->
    <CourseUploadFiles
      ref="uploadDialog"
      :courseFormId="courseFormId"
    />
    <!--    页面-->
    <CourseNewsPage
      ref="pageRef"
      @addRow="addRow"
      @editRow="editRow"
      @uploadRow="uploadRow"
    />
    <!--    编辑or添加-->
    <CourseNewsAddOrEditDialog
      ref="dialogRef"
      :courseFormId="courseFormId"
      :action="action"
      @load="load"
    />
  </div>
</template>

<script lang='ts' setup>
import CourseNewsPage from '@/views/page/tearchertack/mycourse/details/courseNews/CourseNewsPage.vue';
import CourseNewsAddOrEditDialog
  from '@/views/page/tearchertack/mycourse/details/courseNews/CourseNewsAddOrEditDialog.vue';
import CourseUploadFiles from '@/views/page/tearchertack/mycourse/details/courseNews/CourseUploadFiles.vue';
import { ref } from 'vue';

// 编辑添加弹窗控制
const dialogRef = ref();
const uploadDialog = ref();
// 添加的父级id
const courseFormId = ref<number>();
// 章节数据
const chapterId = ref();
// 请求方式
const action = ref();
const pageRef = ref();

// 获取课程下的所有主章节
const load = () => {
  pageRef.value.getCourseList();
};

// 添加章节
const addRow = (parentId: number) => {
  courseFormId.value = parentId;
  action.value = 'post';
  dialogRef.value.openDialog();
};

// 编辑章节
const editRow = (courseId: any) => {
  action.value = 'put';
  dialogRef.value.editDialog(courseId);
};

// 上传课程资源
const uploadRow = (parentId: number) => {
  uploadDialog.value.openDialog(parentId);
};
</script>

<style scoped>

</style>
